home *** CD-ROM | disk | FTP | other *** search
/ NeXT Education Software Sampler 1992 Fall / NeXT Education Software Sampler 1992 Fall.iso / Programming / Source / winterp-1.13 / src-server / w_libXt.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-10-04  |  24.7 KB  |  772 lines

  1. /* -*-C-*-
  2. ********************************************************************************
  3. *
  4. * File:         w_libXt.c
  5. * RCS:          $Header: w_libXt.c,v 1.3 91/03/14 03:13:47 mayer Exp $
  6. * Description:  Random XLISP Primitives and Methods for the Xt Intrinsics
  7. * Author:       Niels Mayer, HPLabs
  8. * Created:      Fri Nov 24 00:36:13 1989
  9. * Modified:     Thu Oct  3 20:51:42 1991 (Niels Mayer) mayer@hplnpm
  10. * Language:     C
  11. * Package:      N/A
  12. * Status:       X11r5 contrib tape release
  13. *
  14. * WINTERP Copyright 1989, 1990, 1991 Hewlett-Packard Company (by Niels Mayer).
  15. * XLISP version 2.1, Copyright (c) 1989, by David Betz.
  16. *
  17. * Permission to use, copy, modify, distribute, and sell this software and its
  18. * documentation for any purpose is hereby granted without fee, provided that
  19. * the above copyright notice appear in all copies and that both that
  20. * copyright notice and this permission notice appear in supporting
  21. * documentation, and that the name of Hewlett-Packard and David Betz not be
  22. * used in advertising or publicity pertaining to distribution of the software
  23. * without specific, written prior permission.  Hewlett-Packard and David Betz
  24. * make no representations about the suitability of this software for any
  25. * purpose. It is provided "as is" without express or implied warranty.
  26. *
  27. * HEWLETT-PACKARD AND DAVID BETZ DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
  28. * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
  29. * IN NO EVENT SHALL HEWLETT-PACKARD NOR DAVID BETZ BE LIABLE FOR ANY SPECIAL,
  30. * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  31. * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  32. * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  33. * PERFORMANCE OF THIS SOFTWARE.
  34. *
  35. * See ./winterp/COPYRIGHT for information on contacting the authors.
  36. * Please send modifications, improvements and bugfixes to mayer@hplabs.hp.com
  37. * Post XLISP-specific questions/information to the newsgroup comp.lang.lisp.x
  38. **
  39. ********************************************************************************
  40. */
  41. static char rcs_identity[] = "@(#)$Header: w_libXt.c,v 1.3 91/03/14 03:13:47 mayer Exp $";
  42.  
  43. #include <stdio.h>
  44. #include <X11/Intrinsic.h>
  45. #include <X11/Shell.h>
  46. #include <Xm/Xm.h>        /* Xm/Xm.h only needed for "winterp.h"*/
  47. #include "winterp.h"
  48. #include "user_prefs.h"
  49. #include "xlisp/xlisp.h"
  50.  
  51. extern Widget Wcls_Get_WIDGETOBJ_Argument_Returning_Validated_WidgetID(); /* w_classes.c */
  52.  
  53. /*****************************************************************************
  54.  * (send <widget> :SET_VALUES 
  55.  *                <resource_1> <value_1>
  56.  *                . . .
  57.  *                <resource_n> <value_n>)
  58.  * ==> returns <widget>
  59.  *
  60.  * void XtSetValues(widget, args, num_args);
  61.  *     Widget           widget;
  62.  *     ArgList          args;
  63.  *     Cardinal         num_args;
  64.  ****************************************************************************/
  65. LVAL Widget_Class_Method_SET_VALUES()
  66. {
  67.   extern ArgList Wres_Get_LispArglist(); /* from w_resources.c */
  68.   extern void    Wres_Free_C_Arglist_Data(); /* from w_resources.c */
  69.   LVAL    self;
  70.   Cardinal xt_numargs;
  71.   ArgList xt_arglist;
  72.   Widget  widget_id;
  73.  
  74.   widget_id = Wcls_Get_WIDGETOBJ_Argument_Returning_Validated_WidgetID(&self);
  75.   
  76.   if (moreargs()) {
  77.     xt_arglist = Wres_Get_LispArglist(self, widget_id, NULL, 0, &xt_numargs);
  78.     XtSetValues(widget_id, xt_arglist, xt_numargs);
  79.     Wres_Free_C_Arglist_Data();
  80.   }
  81.   else
  82.     xlfail("In widget :set_values method, no arguments were given.");
  83.   
  84.   return (self);
  85. }
  86.  
  87.  
  88. /*****************************************************************************
  89.  * (send <widget> :GET_VALUES 
  90.  *                <resource_1> <place_1>
  91.  *                . . .
  92.  *                <resource_n> <place_n>)
  93.  * where <place_i> is a the place to put <resource_i>. If <place_i> is NIL,
  94.  * then <resource_i>'s value is returned in a list. If <place_i> is a quoted
  95.  * symbol, then that symbol gets <resource_i>'s value. If <place_i> is a 
  96.  * place-form (see 'setf') then <resource_i>'s value will be put in <place_i>:
  97.  *         <place>     the field specifier (quoted):
  98.  *                        <sym>                   set value of a symbol
  99.  *                        (car <expr>)            set car of a cons node
  100.  *                        (cdr <expr>)            set cdr of a cons node
  101.  *                        (nth <n> <expr>)        set nth car of a list
  102.  *                        (aref <expr> <n>)       set nth element of an array
  103.  *                        (get <sym> <prop>)      set value of a property
  104.  *                        (symbol-value <sym>)    set value of a symbol
  105.  *                        (symbol-function <sym>) set functional value of a symbol
  106.  *                        (symbol-plist <sym>)    set property list of a symbol
  107.  *
  108.  * void XtGetValues(widget, args, num_args);
  109.  *     Widget           widget;
  110.  *     ArgList          args;
  111.  *     Cardinal         num_args;
  112.  ****************************************************************************/
  113. LVAL Widget_Class_Method_GET_VALUES()
  114. {
  115.   extern ArgList Wres_Get_GetValues_ArgList();    /* from w_resources.c */
  116.   extern LVAL    Wres_GetValues_ArgList_To_Lisp(); /* from w_resources.c */
  117.   LVAL    self;
  118.   Cardinal xt_numargs;
  119.   ArgList xt_arglist;
  120.   Widget  widget_id;
  121.  
  122.   widget_id = Wcls_Get_WIDGETOBJ_Argument_Returning_Validated_WidgetID(&self);
  123.  
  124.   if (moreargs()) {
  125.     xt_arglist = Wres_Get_GetValues_ArgList(&xt_numargs);
  126.     XtGetValues(widget_id, xt_arglist, xt_numargs);
  127.     return (Wres_GetValues_ArgList_To_Lisp(xt_arglist, xt_numargs)); /* sets the variables assoc'd w/ resource and/or return list of vars that weren't set */
  128.   }
  129.   else
  130.     xlfail("In widget :get_values method, no arguments were given.");
  131. }
  132.  
  133.  
  134. /*****************************************************************************
  135.  * (send <widget> :destroy) -- destroy a widget. 
  136.  * ==> returns NIL.
  137.  *
  138.  * After calling this routine, the WIDGETOBJ may be garbage collected, along
  139.  * with all other resources the widget references, such as PIXMAPs CALLBACKOBJs,
  140.  * and EVHANDLEROBJs. Furthermore, this will destroy all children of the
  141.  * destoyed widget and allow their storage to be garbage collected as well.
  142.  *
  143.  * void XtDestroyWidget (widget);
  144.  *     Widget widget;
  145.  ****************************************************************************/
  146. LVAL Widget_Class_Method_DESTROY()
  147. {
  148.   LVAL self;
  149.   Widget widget_id;
  150.  
  151.   widget_id = Wcls_Get_WIDGETOBJ_Argument_Returning_Validated_WidgetID(&self);
  152.   xllastarg();
  153.  
  154.   XtDestroyWidget(widget_id);
  155.   return (NIL);
  156. }
  157.  
  158.  
  159. /*****************************************************************************
  160.  * (send <widget> :MANAGE)
  161.  * ==> returns <widget>
  162.  *
  163.  * This method will add <widget> to it's parent-widget's managed
  164.  * list, which means it will become visible (if mapped) and will take up space
  165.  * within the managing widget.
  166.  *
  167.  * void XtManageChild (child);
  168.  *      Widget    child;
  169.  ****************************************************************************/
  170. LVAL Widget_Class_Method_MANAGE()
  171. {
  172.   LVAL self;
  173.   Widget widget_id;
  174.  
  175.   widget_id = Wcls_Get_WIDGETOBJ_Argument_Returning_Validated_WidgetID(&self);
  176.   xllastarg();
  177.  
  178.   XtManageChild(widget_id);
  179.   return (self);
  180. }
  181.  
  182.  
  183. /*****************************************************************************
  184.  * (send <widget> :UNMANAGE)
  185.  * ==> returns <widget>
  186.  *
  187.  * This method will remove <widget> from its parent's
  188.  * managed list, which means it will no longer be visible or take up space.
  189.  *
  190.  * void XtUnmanageChild (child);
  191.  *     Widget child;
  192.  ****************************************************************************/
  193. LVAL Widget_Class_Method_UNMANAGE()
  194. {
  195.   LVAL self;
  196.   Widget widget_id;
  197.  
  198.   widget_id = Wcls_Get_WIDGETOBJ_Argument_Returning_Validated_WidgetID(&self);
  199.   xllastarg();
  200.  
  201.   XtUnmanageChild(widget_id);
  202.   return (self);
  203. }
  204.  
  205. /******************************************************************************/
  206. #define WIDGETLIST_SIZE_INCREMENT 20
  207. static Cardinal widgetlist_size = 0;
  208. static WidgetList widgetlist = NULL;
  209. WidgetList Get_Widget_List_or_Vector_Argument_Returning_WidgetList(num_children)
  210.      Cardinal *num_children;
  211. {
  212.   register Cardinal size, i;
  213.   LVAL elt, lval_widgets;
  214.   
  215.   lval_widgets = xlgetarg();
  216.  
  217.   if (vectorp(lval_widgets)) {
  218.     *num_children = size = (Cardinal) getsize(lval_widgets); /* get number of widgets */
  219.     if (size > widgetlist_size) { /* make sure it'll fit in current widgetlist array */
  220.       if (widgetlist)
  221.     widgetlist = (Widget*) XtRealloc(widgetlist, (unsigned) (size * sizeof(Widget)));
  222.       else
  223.     widgetlist = (Widget*) XtMalloc((unsigned) (size * sizeof(Widget)));
  224.       widgetlist_size = size;
  225.     }
  226.     for (i = 0 ; (i < size) ; i++) {
  227.       elt = getelement(lval_widgets, i);
  228.       if (widgetobj_p(elt)) {
  229.     if (!(widgetlist[i] = get_widgetobj_widgetID(elt)))
  230.       xlerror("widget object has been :destroy'd or hasn't been initialized by :isnew.", elt);
  231.       }
  232.       else
  233.     xlerror("Bad widget-vector element -- expected a vector of WIDGETOBJs.", elt);
  234.     }
  235.   }
  236.   else if (consp(lval_widgets)) {
  237.     for (i = 0 ; (consp(lval_widgets)) ; lval_widgets = cdr(lval_widgets), i++) {
  238.       if (i >= widgetlist_size)    { /* make sure it'll fit in current widgetlist array */
  239.     if (widgetlist)
  240.       widgetlist = (Widget*) XtRealloc(widgetlist, (unsigned) ((widgetlist_size + WIDGETLIST_SIZE_INCREMENT) * sizeof(Widget)));
  241.     else
  242.       widgetlist = (Widget*) XtMalloc((unsigned) (WIDGETLIST_SIZE_INCREMENT * sizeof(Widget)));
  243.     widgetlist_size += WIDGETLIST_SIZE_INCREMENT;
  244.       }
  245.       elt = car(lval_widgets);
  246.       if (widgetobj_p(elt)) {
  247.     if (!(widgetlist[i] = get_widgetobj_widgetID(elt)))
  248.       xlerror("widget object has been :destroy'd or hasn't been initialized by :isnew.", elt);
  249.       }
  250.       else
  251.     xlerror("Bad widget-list element -- expected a list of WIDGETOBJs.", elt);
  252.     }
  253.     if (lval_widgets)        /* if loop terminated due to list pointer not being a CONS cell */
  254.       xlerror("Bad widget-list element -- expected a list of WIDGETOBJs.", lval_widgets);
  255.     *num_children = i;
  256.   }
  257.   else
  258.     xlerror("Bad argument type -- expected a list or vector of WIDGETOBJs.", lval_widgets);
  259.  
  260.   return (widgetlist);        /* DO NOT FREE THIS RESULT */
  261. }
  262.  
  263. /******************************************************************************
  264.  * (XT_MANAGE_CHILDREN <widgets...>)
  265.  * ==> returns T.
  266.  * 
  267.  * Given a vector or list of widgets, all of which must be children of the
  268.  * same parent, this will add those widgets to their parent-widget's managed
  269.  * list, which means they will become visible (if mapped) and will take up space
  270.  * within the managing widget.
  271.  *
  272.  * An error will be signalled if the widgets passed to this routine  do not
  273.  * all have the same parent.
  274.  *
  275.  * void XtManageChildren(children, num_children)
  276.  *     WidgetList children;
  277.  *     Cardinal   num_children;
  278.  ******************************************************************************/
  279. LVAL Wxt_Prim_XT_MANAGE_CHILDREN()
  280. {
  281.   WidgetList children;
  282.   Cardinal num_children;
  283.   extern LVAL true;
  284.  
  285.   children = Get_Widget_List_or_Vector_Argument_Returning_WidgetList(&num_children);
  286.   xllastarg();
  287.  
  288.   XtManageChildren(children, num_children);
  289.  
  290.   return (true);
  291. }
  292.  
  293. /******************************************************************************
  294.  * (XT_UNMANAGE_CHILDREN <widgets...>)
  295.  * ==> returns T.
  296.  * 
  297.  * Given a vector or list of widgets, all of which must be children of the
  298.  * same parent, this will remove those child-widgets from their parent's
  299.  * managed list, which means they will no longer be visible or take up space.
  300.  *
  301.  * An error will be signalled if the widgets passed to this routine  do not
  302.  * all have the same parent.
  303.  *
  304.  * void XtUnmanageChildren (children, num_children)
  305.  *     WidgetList children;
  306.  *     Cardinal   num_children;
  307.  ******************************************************************************/
  308. LVAL Wxt_Prim_XT_UNMANAGE_CHILDREN()
  309. {
  310.   WidgetList children;
  311.   Cardinal num_children;
  312.   extern LVAL true;
  313.  
  314.   children = Get_Widget_List_or_Vector_Argument_Returning_WidgetList(&num_children);
  315.   xllastarg();
  316.  
  317.   XtUnmanageChildren(children, num_children);
  318.  
  319.   return (true);
  320. }
  321.  
  322.  
  323. /******************************************************************************
  324.  * (send <widget> :ADD_GRAB <exclusive_p> <spring_loaded_p>)
  325.  * ==>  returns <widget>
  326.  *
  327.  * Appends <widget> to the modal cascade -- redirects user input to this widget
  328.  * <exclusive_p> and <spring_loaded_p> are booleans.
  329.  *
  330.  * void XtAddGrab(widget, exclusive, spring_loaded)
  331.  *      Widget  widget;
  332.  *      Boolean exclusive;
  333.  *      Boolean spring_loaded;
  334.  ******************************************************************************/
  335. LVAL Widget_Class_Method_ADD_GRAB()
  336. {
  337.   LVAL self, exclusive_p, spring_loaded_p;
  338.   Widget widget_id;
  339.  
  340.   widget_id = Wcls_Get_WIDGETOBJ_Argument_Returning_Validated_WidgetID(&self);
  341.   exclusive_p = xlgetarg();
  342.   spring_loaded_p = xlgetarg();
  343.   xllastarg();
  344.  
  345.   XtAddGrab(widget_id,
  346.         (exclusive_p) ? TRUE : FALSE,
  347.         (spring_loaded_p) ? TRUE : FALSE);
  348.   return (self);
  349. }
  350.  
  351.  
  352. /******************************************************************************
  353.  * (send <widget> :REMOVE_GRAB)
  354.  * ==>  returns <widget>
  355.  *
  356.  * Removes redirection of user input to <widget>.
  357.  * 
  358.  * void XtRemoveGrab(widget)
  359.  *     Widget  widget;
  360.  ******************************************************************************/
  361. LVAL Widget_Class_Method_REMOVE_GRAB()
  362. {
  363.   LVAL self;
  364.   Widget widget_id;
  365.  
  366.   widget_id = Wcls_Get_WIDGETOBJ_Argument_Returning_Validated_WidgetID(&self);
  367.   xllastarg();
  368.  
  369.   XtRemoveGrab(widget_id);
  370.   return (self);
  371. }
  372.  
  373.  
  374. /******************************************************************************
  375.  * (send <widget> :IS_COMPOSITE)
  376.  * ==> returns T if <widget> is a composite widget,  else NIL.
  377.  *
  378.  * #define XtIsCompositeObject(widget) XtIsSubclass(widget, (WidgetClass) compositeObjectClass)
  379.  ******************************************************************************/
  380. LVAL Widget_Class_Method_IS_COMPOSITE()
  381. {
  382.   extern LVAL true;
  383.   LVAL self;
  384.   Widget widget_id;
  385.  
  386.   widget_id = Wcls_Get_WIDGETOBJ_Argument_Returning_Validated_WidgetID(&self);
  387.   xllastarg();
  388.  
  389.  
  390. #ifndef WINTERP_MOTIF_11
  391.   return (XtIsCompositeObject(widget_id) ? true : NIL);
  392. #else
  393.   return (XtIsComposite(widget_id) ? true : NIL);
  394. #endif /* WINTERP_MOTIF_11 */
  395.  
  396.  
  397. }
  398.  
  399.  
  400. /******************************************************************************
  401.  * (send <widget> :IS_CONSTRAINT)
  402.  * ==> returns T if <widget> is a constraint widget, else NIL.
  403.  *
  404.  * #define XtIsConstraint(widget)      XtIsSubclass(widget, (WidgetClass) constraintWidgetClass)
  405.  ******************************************************************************/
  406. LVAL Widget_Class_Method_IS_CONSTRAINT()
  407. {
  408.   extern LVAL true;
  409.   LVAL self;
  410.   Widget widget_id;
  411.  
  412.   widget_id = Wcls_Get_WIDGETOBJ_Argument_Returning_Validated_WidgetID(&self);
  413.   xllastarg();
  414.  
  415.   return (XtIsConstraint(widget_id) ? true : NIL);
  416. }
  417.  
  418.  
  419. /******************************************************************************
  420.  * (send <widget> :IS_SHELL)
  421.  * ==> returns T if <widget> is a shell widget, else NIL.
  422.  *
  423.  * #define XtIsShell(widget)        XtIsSubclass(widget, (WidgetClass) shellWidgetClass)
  424.  ******************************************************************************/
  425. LVAL Widget_Class_Method_IS_SHELL()
  426. {
  427.   extern LVAL true;
  428.   LVAL self;
  429.   Widget widget_id;
  430.  
  431.   widget_id = Wcls_Get_WIDGETOBJ_Argument_Returning_Validated_WidgetID(&self);
  432.   xllastarg();
  433.  
  434.   return (XtIsShell(widget_id) ? true : NIL);
  435. }
  436.  
  437.  
  438. /******************************************************************************
  439.  * (send <widget> :SET_SENSITIVE <sensitive_p>)
  440.  * ==> returns <widget>.
  441.  *
  442.  * If <sensitive_p> is NIL, then the widget will not respond to user input.
  443.  *
  444.  * void XtSetSensitive (widget, sensitive)
  445.  *      Widget    widget;
  446.  *      Boolean   sensitive;
  447.  ******************************************************************************/
  448. LVAL Widget_Class_Method_SET_SENSITIVE()
  449. {
  450.   LVAL self, sensitive_p;
  451.   Widget widget_id;
  452.  
  453.   widget_id = Wcls_Get_WIDGETOBJ_Argument_Returning_Validated_WidgetID(&self);
  454.   sensitive_p = xlgetarg();
  455.   xllastarg();
  456.  
  457.   XtSetSensitive(widget_id, 
  458.          (sensitive_p) ? TRUE : FALSE);
  459.   return (self);
  460. }
  461.  
  462.  
  463. /******************************************************************************
  464.  * (send <widget> :SET_MAPPED_WHEN_MANAGED <mapped_p>)
  465.  * ==> returns <widget>.
  466.  *
  467.  * If <mapped_p> is non-NIL, then the widget will be mapped (displayed).
  468.  *
  469.  * void XtSetMappedWhenManaged()
  470.  *      Widget    widget;
  471.  *      Boolean   mappedWhenManaged;
  472.  ******************************************************************************/
  473. LVAL Widget_Class_Method_SET_MAPPED_WHEN_MANAGED()
  474. {
  475.   LVAL self, mapped_p;
  476.   Widget widget_id;
  477.  
  478.   widget_id = Wcls_Get_WIDGETOBJ_Argument_Returning_Validated_WidgetID(&self);
  479.   mapped_p = xlgetarg();
  480.   xllastarg();
  481.  
  482.   XtSetMappedWhenManaged(widget_id, 
  483.              (mapped_p) ? TRUE : FALSE);
  484.   return (self);
  485. }
  486.  
  487. /******************************************************************************
  488.  * (send <widget> :IS_MANAGED)
  489.  * ==> returns T if the widget is managed, else NIL. See method :MANAGE.
  490.  *
  491.  * Boolean XtIsManaged(widget)
  492.  *        Widget widget;
  493.  ******************************************************************************/
  494. LVAL Widget_Class_Method_IS_MANAGED()
  495. {
  496.   extern LVAL true;
  497.   LVAL self;
  498.   Widget widget_id;
  499.  
  500.   widget_id = Wcls_Get_WIDGETOBJ_Argument_Returning_Validated_WidgetID(&self);
  501.   xllastarg();
  502.  
  503.   return (XtIsManaged(widget_id) ? true : NIL);
  504. }
  505.  
  506.  
  507. /******************************************************************************
  508.  * (send <widget> :IS_REALIZED)
  509.  * ==> returns T if the widget is realized, else NIL. See method :REALIZE.
  510.  *
  511.  * Boolean XtIsRealized (widget);
  512.  *         Widget widget;
  513.  ******************************************************************************/
  514. LVAL Widget_Class_Method_IS_REALIZED()
  515. {
  516.   extern LVAL true;
  517.   LVAL self;
  518.   Widget widget_id;
  519.  
  520.   widget_id = Wcls_Get_WIDGETOBJ_Argument_Returning_Validated_WidgetID(&self);
  521.   xllastarg();
  522.  
  523.   return (XtIsRealized(widget_id) ? true : NIL);
  524. }
  525.  
  526.  
  527. /******************************************************************************
  528.  * (send <widget> :IS_SENSITIVE)
  529.  * ==> returns T if the widget will accept user input, else NIL. See also
  530.  * method :SET_SENSITIVE.
  531.  *
  532.  * Boolean XtIsSensitive(widget);
  533.  *         Widget widget;
  534.  ******************************************************************************/
  535. LVAL Widget_Class_Method_IS_SENSITIVE()
  536. {
  537.   extern LVAL true;
  538.   LVAL self;
  539.   Widget widget_id;
  540.  
  541.   widget_id = Wcls_Get_WIDGETOBJ_Argument_Returning_Validated_WidgetID(&self);
  542.   xllastarg();
  543.  
  544.   return (XtIsSensitive(widget_id) ? true : NIL);
  545. }
  546.  
  547. /*****************************************************************************
  548.  * (send <widget> :PARENT)
  549.  * ==> returns the given <widget>'s parent widget or NIL if no parent.
  550.  *
  551.  * Widget XtParent(widget)
  552.  *        Widget widget;
  553.  *
  554.  * Note: for Motif 1.1 bug workaround for calling :PARENT on
  555.  * XmList/:scrolled and XmText/:scrolled widgets, see methods
  556.  * Xm_List_Widget_Class_Method_PARENT() and Xm_Text_Widget_Class_Method_PARENT()
  557.  ****************************************************************************/
  558. LVAL Widget_Class_Method_PARENT()
  559. {
  560.   extern LVAL Wcls_WidgetID_To_WIDGETOBJ();
  561.   LVAL self;
  562.   Widget widget_id;
  563.  
  564.   widget_id = Wcls_Get_WIDGETOBJ_Argument_Returning_Validated_WidgetID(&self);
  565.   xllastarg();
  566.  
  567.   return (Wcls_WidgetID_To_WIDGETOBJ(XtParent(widget_id)));
  568. }
  569.  
  570.  
  571. /*****************************************************************************
  572.  * (send <widget> :WINDOW)
  573.  * ==> returns the given <widget>'s window.
  574.  *
  575.  * Window XtWindow(Widget);
  576.  * Window XtWindowOfObject(Widget);
  577.  ****************************************************************************/
  578. LVAL Widget_Class_Method_WINDOW()
  579. {
  580.   LVAL self;
  581.   Widget widget_id;
  582.   Window window_id;
  583.  
  584.   widget_id = Wcls_Get_WIDGETOBJ_Argument_Returning_Validated_WidgetID(&self);
  585.   xllastarg();
  586.  
  587. #ifdef WINTERP_MOTIF_11
  588.   if (window_id = XtWindowOfObject(widget_id))
  589. #else
  590.   if (window_id = XtWindow(widget_id))
  591. #endif /* WINTERP_MOTIF_11 */
  592.     return (cv_window(window_id));
  593.   else
  594.     return (NIL);
  595. }
  596.  
  597.  
  598. /*****************************************************************************
  599.  * (send <widget> :MAP)
  600.  * ==> returns <widget>.
  601.  *
  602.  * If the widget is realized and managed, this method will make the window
  603.  * appear on the display. Make it disappear with :UNMAP.
  604.  *
  605.  * #define XtMapWidget(widget)    XMapWindow(XtDisplay(widget), XtWindow(widget))
  606.  ****************************************************************************/
  607. LVAL Widget_Class_Method_MAP()
  608. {
  609.   LVAL self;
  610.   Widget widget_id;
  611.  
  612.   widget_id = Wcls_Get_WIDGETOBJ_Argument_Returning_Validated_WidgetID(&self);
  613.   xllastarg();
  614.  
  615.   if (
  616. #ifdef WINTERP_MOTIF_11
  617.       XtIsWidget(widget_id)
  618. #else
  619.       XtIsWindowObject(widget_id)
  620. #endif                /* WINTERP_MOTIF_11 */
  621.       ) {
  622.     XtMapWidget(widget_id);
  623.     return (self);
  624.   }
  625.   else 
  626.     xlerror("Method :MAP only applies to widgets, not gadgets.", self);
  627. }
  628.  
  629.  
  630. /*****************************************************************************
  631.  * (send <widget> :UNMAP)
  632.  * ==> returns <widget>.
  633.  *
  634.  * If the widget is realized and managed, this method will make the window
  635.  * disappear from the display. Make it reappear with :MAP.
  636.  *
  637.  * #define XtUnmapWidget(widget) XUnmapWindow(XtDisplay(widget), XtWindow(widget))
  638.  ****************************************************************************/
  639. LVAL Widget_Class_Method_UNMAP()
  640. {
  641.   LVAL self;
  642.   Widget widget_id;
  643.  
  644.   widget_id = Wcls_Get_WIDGETOBJ_Argument_Returning_Validated_WidgetID(&self);
  645.   xllastarg();
  646.  
  647.   if (
  648. #ifdef WINTERP_MOTIF_11
  649.       XtIsWidget(widget_id)
  650. #else
  651.       XtIsWindowObject(widget_id)
  652. #endif                /* WINTERP_MOTIF_11 */
  653.       ) {
  654.     XtUnmapWidget(widget_id);
  655.     return (self);
  656.   }
  657.   else 
  658.     xlerror("Method :UNMAP only applies to widgets, not gadgets.", self);
  659. }
  660.  
  661.  
  662. #ifdef WINTERP_MOTIF_11        /* actually, just X11r4, but Motif1.1-->X11r4 */
  663. /*****************************************************************************
  664.  * (send <widget> :NAME)
  665.  * ==> returns string of widget's name.
  666.  *
  667.  * extern String XtName(Widget object);
  668.  ****************************************************************************/
  669. LVAL Widget_Class_Method_NAME()
  670. {
  671.   LVAL self;
  672.   Widget widget_id;
  673.  
  674.   widget_id = Wcls_Get_WIDGETOBJ_Argument_Returning_Validated_WidgetID(&self);
  675.   xllastarg();
  676.  
  677.   return (cvstring((char*) XtName(widget_id)));    /* XtName String return is copied by cvstring(), copy is freed by XLISP-GC */
  678. }
  679. #endif /* WINTERP_MOTIF_11 */
  680.  
  681.  
  682. #ifdef WINTERP_MOTIF_11
  683. /******************************************************************************
  684.  * (XT_RESOLVE_PATHNAME <type> <filename> <suffix> <path>)
  685.  *    ==> returns a string representing the pathname of an existing file
  686.  *        created from the parameters  <type> <filename> <suffix> <path>.
  687.  *        will return NIL if no such file exists, is readable, and
  688.  *        isn't a directory.
  689.  *
  690.  * where
  691.  *
  692.  * <path> is a string of paths separated by colons (':'), in which the 
  693.  *     following substituions are done:
  694.  *    %N -- gets substituted by the parameter <filename>, a name without the extension.
  695.  *    %T -- gets substituted by the parameter <type>, a directory name. 
  696.  *    %S -- gets substituted by the parameter <suffix>.
  697.  *    
  698.  *    X11r4 Language-dependent substitutions for %L, %l %t, %c may occur as well.
  699.  *    See the documentation for XtResolvePathname() for further details.
  700.  *
  701.  * <type> is a STRING, or NIL. This substitutes for occurrences of %T in <path>.
  702.  *
  703.  * <filename> is a STRING. If this parameter is NIL, then note that XtResolvePathname()
  704.  *    will substitute the application class name.
  705.  *
  706.  * <suffix> is a STRING, or NIL. This substitutes for occurrences of %S in <path>.
  707.  * 
  708.  * String XtResolvePathname(
  709.  *     Display*    dpy,
  710.  *     CONST String type,
  711.  *     CONST String filename,
  712.  *     CONST String suffix,
  713.  *     CONST String path,
  714.  *     Substitution substitution,
  715.  *     Cardinal num_substitutions,
  716.  *     XtFilePredicate predicate)
  717.  ******************************************************************************/
  718. LVAL Wxt_Prim_XT_RESOLVE_PATHNAME()
  719. {
  720.   extern Display* display;    /* global in winterp.c */
  721.   String type, filename, suffix, path;
  722.   String result;
  723.   /*  LVAL lval_result; */
  724.  
  725.   if (moreargs() && (*xlargv == NIL)) {    /* get <type> */
  726.     type = NULL;
  727.     nextarg();
  728.   }
  729.   else
  730.     type = (String) getstring(xlgastring());
  731.  
  732.   if (moreargs() && (*xlargv == NIL)) {    /* get <filename> */
  733.     filename = NULL;
  734.     nextarg();
  735.   }
  736.   else
  737.     filename = (String) getstring(xlgastring());
  738.  
  739.   if (moreargs() && (*xlargv == NIL)) {    /* get <suffix> */
  740.     suffix = NULL;
  741.     nextarg();
  742.   }
  743.   else
  744.     suffix = (String) getstring(xlgastring());
  745.  
  746.   if (moreargs() && (*xlargv == NIL)) {    /* get <path> */
  747.     path = NULL;
  748.     nextarg();
  749.   }
  750.   else
  751.     path = (String) getstring(xlgastring());
  752.  
  753.   xllastarg();
  754.  
  755.   result = XtResolvePathname(display, type, filename, suffix, path,
  756.                  (Substitution) NULL, 0,
  757.                  (XtFilePredicate) NULL);
  758.  
  759.   if (result) {
  760. /*
  761.     lval_result = cvstring(result);
  762.     XtFree(result);
  763.     return (lval_result);
  764. */
  765.     return (cv_string(result));    /* XtResolvePathname() result is not copied, will be freed by XLISP-GC */
  766.   }
  767.   else
  768.     return (NIL);
  769. }
  770. #endif
  771.